<?php
/**
*btc列表
*/
require_once 'common.inc.php';
include_once 'include/mysql_info.php';
$torrent = new dbstuff;
$torrent->connect($dphost, $dpuser, $dppw, $db_torrent, $dppconnect);
$torrent_db = $torrent;
//torrent统计数据库专用链接
error_reporting(0);
if('list'==$action)
{	
/*	$limit = 10;
	$page = intval($page) < 1?1:intval($page);
	$start = (intval($page)-1) * $limit;
	$torrent_sql = "select count(*) from c_torrent ";
	$query = $torrent_db -> query($torrent_sql);
	$count = $torrent_db -> fetch_array($query);
	$allpage = ceil($count['count(*)'] / $limit);
	$page = $page > $allpage?$allpage:$page;
	$url = 'actorrent.inc.php?action=' . $action . '&amp;';
	$pages = numofpage($count['count(*)'], $page, $allpage, $url);

	$now=time();
	$old=time()-86400;

	$sql="select sum(ccount) from c_torrent where ctime<='$now'and ctime>='$old'";
	$query=$torrent_db->query($sql);
	$sum=$torrent_db->fetch_array($query);
*/	
	//显示当前ACS的IP和端口
	$sql="select host from c_torrent order by host asc";
	$query=$torrent_db->query($sql);
	while($result=$torrent_db->fetch_array($query)){
		$row[]=$result;
		if(!in_array($result['host'],$listhost)&&$result['host'])
		{
			$oldhost=$result['host'];
			$listhost[]=$oldhost;
		}
	}
	
	include_once MCC_ROOT.'/templates/msystem/accountlist.htm';
}
/*elseif('search'==$action)
{	
	$stimeo=$stime;
	$etimeo=$etime;
	if(!ereg("-",$stimeo))$stimeo=date('Y-m-d',$stimeo);
	if(!ereg("-",$etimeo))$etimeo=date('Y-m-d',$etimeo);
	if(empty($page))
	{
		$stime=GmtToUnix($stime);
		$etime=GmtToUnix($etime);
	}
	if($stime>$etime)
		adminmsg('时间参数错误','actorrent.inc.php?action=list');	
	else
	{
		$limit = 10;
		$page = intval($page) < 1?1:intval($page);
		$start = (intval($page)-1) * $limit;
		$sql = "select count(*) from c_torrent where ctime>='$stime' and ctime<='$etime'";
		$query = $torrent_db -> query($sql);
		$count = $torrent_db -> fetch_array($query);
		//print_r($count);
		$allpage = ceil($count['count(*)'] / $limit);
		$page = $page > $allpage?$allpage:$page;
		$url = 'actorrent.inc.php?action=' . $action . '&amp;stime='.$stime.'&amp;etime='.$etime.'&amp;';
		$pages = numofpage($count['count(*)'], $page, $allpage, $url);

		$sql="select * from c_torrent where ctime>='$stime' and ctime<='$etime' order by ctime desc  limit $start,$limit";
		$query = $torrent_db -> query($sql);
		while($result=$torrent_db->fetch_array($query)){
			$row[]=$result;			
		}

	$sql="select sum(ccount) from c_torrent where ctime>='$stime' and ctime<='$etime'";
	$query=$torrent_db->query($sql);
	$sum=$torrent_db->fetch_array($query);

	include_once MCC_ROOT.'/templates/msystem/accountlist.htm';
	}
}
/*


function getConnectNum()
{	
	global $tra_db;
	$tracker=array();
	$query=$tra_db->query("select * from acsconnect order by aip,atime desc limit 10");
   	$kl=0;
	$qu="";
	while($tracker=$tra_db->fetch_array($query))
	{
		$str="";
		$str=explode(':',$tracker['aip']);
		$acshost[]=$str[0];
		$acsport[]=$str[1];
		$port=$acsport[$kl];
		$newtime=explode(" ",microtime());
		$atime=$newtime[1];
		echo "<br>发送协议：{$acshost[$kl]}主机，端口号：{$acsport[$kl]}信息：";
		$str="21321";
		//if($str=sendin($msg,$host,$port))
		$tra_db->query(" insert into acsconnect(aip,agetport,asendport,atime,acount) values ('".$acshost[$kl]."','".$acsport[$kl]."','".$port."','".$atime."','".$str."'); ");
		$kl++;
	}
}	


*/
function GmtToUnix($GmtDate)
{
 $DateArr = explode(' ',$GmtDate); // 分割GMT日期为 日期 | 时间

 /* 在日期中取得年,月,日 */
 $pDate = split('[/.-]',$DateArr[0]);
 $Year = $pDate[0];
 $Month = $pDate[1];
 $Day = $pDate[2];
 
 /* 在时间中取得时,分,秒 */
 $pTime = split('[:.-]',$DateArr[1]);
 $Hour = $pTime[0];
 $Minute = $pTime[1];
 $Second = $pTime[2];
 
 if($Year == '' || !is_numeric($Year))$Year = 0;
 if($Month == '' || !is_numeric($Month))$Month = 0;
 if($Day == '' || !is_numeric($Day))$Day = 0;
 if($Hour == '' || !is_numeric($Hour))$Hour = 0;
 if($Minute == '' || !is_numeric($Minute))$Minute = 0;
 if($Second == '' || !is_numeric($Second))$Second = 0;
 return mktime($Hour,$Minute,$Second,$Month,$Day,$Year);
}

?>